package com.xx.controller;

import com.xx.domain.Permission;
import com.xx.domain.Role;
import com.xx.service.RoleServce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

/**
 * @Author : 徐闯 ssm_admin
 * @Date : 2021-05-18 11:05:08
 * @Description : 角色操作的控制器
 **/
@Controller
@ResponseBody
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleServce roleServce;
    @RequestMapping("/findALl")
    public List<Role> findALlRole(){
        return roleServce.findALl();
    }
    @RequestMapping("/insertOne")
    public int insertRole(Role role){
        return roleServce.insertOne(role);
    }
    @RequestMapping("/deleteOne")
    public int deleteOne(int rId){
        return roleServce.deleteOne(rId);
    }
    @RequestMapping("/deleteAll")
    public int deleteALl(int rIds[]){
        return roleServce.deleteAll(rIds);
    }
    @RequestMapping("/findPermission")
    public List<Permission> findPermission(int rId){
        return roleServce.findList(rId);
    }
    @RequestMapping("/insertPermission")
    public int insertPermission(int rId, @RequestParam("pList[]")int[] pList){
        HashMap map = new HashMap();
        map.put("rId",rId);
        map.put("pList",pList);
        return roleServce.insertPermission(map);
    }
}
